home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / dbread2.zip / DBREAD.DOC < prev    next >
Text File  |  1992-01-08  |  3KB  |  81 lines

  1. This is some sample C code for openning and reading the structure of a
  2. dBASE DBF file.  If you find any bugs, please report them to HMAN on
  3. this BBS.  The code is commented but requires a familiarity with the C
  4. programming language. This is provided free of charge for those curious
  5. in dabbling with C in conjunction with dBASE databases.
  6.  
  7. One thing I noticed in the development of this code is that if you
  8. delete a production dBASE IV MDX file and subsequently USE that database
  9. and choose to Proceed when notified about the missing MDX, the first
  10. byte in the database is updated to indicate that no production MDX file
  11. should be present.  However, the Production .MDX flags in the field
  12. descriptor array are not updated.  I have reported this as a bug but
  13. don't know what will become of it.  It is something that you should be
  14. aware of if you are going to get heavily into .DBF manipulation.
  15.  
  16. These programs were written and compiled using Microsoft QuickC 2.5 but
  17. should be easily modified for other C compilers.
  18.  
  19. To run the compiled program, type DBREAD followed by the name of the DBF
  20. file to be read.  If no extension is specified, a .DBF extension is
  21. added to the specified file name.
  22.  
  23. DBREAD.COM is a very simple program that opens the specified file and
  24. assumes it is a DBF file and attempts to list its structure.  It does
  25. not validate the file as truly being a DBF file and does not accept
  26. wildcard file names.  No attempt is made to read the fields list of
  27. encrypted files as this information is also encrypted and un-readable.
  28. Also, it does _not_ work with dBASE II files.
  29.  
  30. DBREAD2.COM is a slightly more complex and useful version of DBREAD.  It
  31. can handle wildcard file names and tries to verify that the file being
  32. read is truly a dBASE database.  I've included it separately because I
  33. wanted DBREAD to be a simple example that shows the core elements of
  34. reading a DBF file.  Also, DBREAD2 ignores the field descriptor array's
  35. indication of the presence of an MDX tag when the header says that there
  36. is no associated MDX file.  DBREAD2 can read dBASE II database and list
  37. their structures as well.
  38.  
  39. If you specify wild cards in the command line argument:
  40.      1) every matching file will be evaluated to see if it a dBASE II or
  41.         III/IV database.  Only those that pass a small set of tests will
  42.         have their structures listed.
  43.      2) if the matching file name has a DBF, DBK, DBB, CVT, CRP, or CAT
  44.         extension but does not pass the tests, a message will be displayed
  45.         on the screen.
  46.      3) if the file does _not_ have a any of the above extensions and does
  47.         not pass the tests, no message is displayed, the file is simply
  48.         ignored.
  49.  
  50. If you specify a single file name and it does not pass the tests, a
  51. message will be displayed.
  52.  
  53. You may not appreciate how hard this was, but I've added the capability
  54. to specify pretty much any valid filespec as input for DBREAD2.  It
  55. works pretty much like the DIR command when it comes to analyzing
  56. wild-card specifications.  You can say
  57.  
  58. DBREAD2 .
  59.  
  60. for all .DBF files in the current drive and directory or
  61.  
  62. DBREAD2 D:
  63.  
  64. for all the .DBF files in the current directory of D:
  65.  
  66. .. is recognized and honored as part of a path specification, but not by
  67. itself, e.g.
  68.  
  69. DBREAD2 ..
  70.  
  71. will _not_ read the files in the parent directory, but
  72.  
  73. DBREAD ..\
  74.  
  75. will read them.
  76.  
  77. Enjoy!
  78.  
  79. Martin R. Leon
  80. Borland Software Support
  81.